<?php
/**
 * Created by PhpStorm.
 * User: tsy
 * Date: 2016/6/15
 * Time: 15:00
 */
namespace Admin\Controller\Report;
use Think\Controller;

class PersonreportController extends Controller{
    /**
     * 个人基本信息报文table
     */
    public function person_report(){
        $start_time=I("post.start_time","");
        $end_time=I("post.end_time","");
        $report=D("Report");
        $report_array=$report->get_person_info($start_time,$end_time);
        $json=json_encode($report_array);
        $this->assign('report_json',$json);

        $search_array['start_time']=$start_time;
        $search_array['end_time']=$end_time;
        $this->assign("search_array",$search_array);
        $this->display();
    }

    /**
     * 个人基本信息报文导出
     */
    public function person_report_export(){
        $start_time=I("post.start_time","");
        $end_time=I("post.end_time","");
        $report=D("Report");
        $report_array=$report->get_person_info($start_time,$end_time);
        $count=count($report_array);

        $person_basic=C("person_basic");
        $identity_info=C("identity_info");
        $profession_info=C("profession_info");
        $live_info=C("live_info");
        $org_code=C("org_code");

        $number_array=C("number_array");
        $flowing_water="";
        for($j=0;$j<3;$j++){
            $k=rand(0,36);
            $flowing_water.=$number_array[$k];
        }
        $dir=$org_code.date("Ymd",time()).$flowing_water."1";
        $file_name=$dir.".txt";
        $path="Public/file/".$file_name;
        $file=fopen($path,"a+");

        $identity_type=0;//身份证类型：0代表身份证
        for($i=0;$i<$count;$i++){
            $cust_name=$report_array[$i]['cust_name'];
            if($cust_name==''){
                continue;
            }
            $cust_name=report_switch($cust_name,30);
            $cust_identity=$report_array[$i]['cust_identity'];
            $cust_sex=$report_array[$i]['cust_sex'];
            $create_date=substr($cust_identity,6,8);
            $marry_status=$report_array[$i]['marry_status'];
            $education_status=$report_array[$i]['education_status'];
            $degree_status=$report_array[$i]['degree_status'];
            $address_phone=str_pad("",25," ",STR_PAD_RIGHT);
            $cust_phone=str_pad(cust_phone,16," ",STR_PAD_RIGHT);
            $company_phone=str_pad("",25," ",STR_PAD_RIGHT);
            $cust_email=str_pad($report_array[$i]['cust_email'],30," ",STR_PAD_RIGHT);
            $communication_address=str_pad();

        }
    }

}